package org.game.db.dao;

import com.sojoys.artifact.manager.DataSourceManager;
import java.sql.Connection;
import com.sojoys.artifact.build.data.base.BaseDao;
import java.util.ArrayList;
import com.sojoys.artifact.manager.JsonManager;
import java.sql.SQLException;
import com.google.common.collect.Lists;
import org.apache.commons.dbutils.handlers.MapHandler;
import com.sojoys.artifact.tools.SK_Plus;
import java.sql.ResultSet;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.commons.dbutils.handlers.MapListHandler;
import com.sojoys.artifact.constant.CreateTableEnum;
import org.game.db.bean.Role;
import com.sojoys.artifact.constant.DataModelKeyEnum;
import org.apache.commons.dbutils.handlers.AbstractListHandler;
import org.apache.commons.dbutils.QueryRunner;
import com.xiaoleilu.hutool.log.Log;
import static org.game.db.StaticResource.RoleResource.*;
import java.util.Set;
import com.sojoys.artifact.constant.ArtifactErrorCode;
import com.xiaoleilu.hutool.util.StrUtil;
import com.sojoys.artifact.tools.ToolError;
import org.apache.commons.dbutils.DbUtils;
import com.xiaoleilu.hutool.log.LogFactory;
import java.util.List;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.dbutils.ResultSetHandler;
import com.google.common.base.Joiner;
import static org.game.db.StaticResource.RoleResource.*;
/**
 * 精灵(板娘)
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public class RoleDaoImpl implements BaseDao<Long,Role>{
	static Log log = LogFactory.get(RoleDaoImpl.class);
	
	// 代理
	
	/**
	 * 私有化无参构造方法
	 */
	private RoleDaoImpl() {}
	  
    private static final RoleDaoImpl INSTANCE = new RoleDaoImpl();  
    
    public static RoleDaoImpl me() {  
        return INSTANCE;  
    }  
	
	public Role insert(Role role){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insert(role,conn);
	}
	
	public Role insert(Role role,Connection conn){
		return insert(role,conn,TABLE_NAME);
	}
	
	public Role insert(Role role,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return insert(role,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public Role insert(Role role,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insert(role,conn,tableName);
	}
	
	public Role insert(Role role,Connection conn,String tableName){
		
		QueryRunner run = new QueryRunner();
		String sql = "INSERT INTO " +tableName+ " (id,cid,player_id,favor,mood,status,create_date,modified_date,unlock_gift,unlock_hobby,dress_dating,donate_dating,last_mood_update_time,work_building_id,critical_point,trigger_dating,today_city_dating_count,last_refresh_time) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		try {
			int i = run.update(conn,sql,role.getId(),role.getCid(),role.getPlayerId(),role.getFavor(),role.getMood(),role.getStatus(),role.getCreateDate(),role.getModifiedDate(),role.getUnlockGiftByte(),role.getUnlockHobbyByte(),role.getDressDatingByte(),role.getDonateDatingByte(),role.getLastMoodUpdateTime(),role.getWorkBuildingId(),role.isCriticalPoint(),role.getTriggerDatingByte(),role.getTodayCityDatingCount(),role.getLastRefreshTime());
			return i > 0 ? role : null;
		} catch (Exception e) {
			log.error(e);
			return null;
		} finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
	}
	
	public Role insert(Role role,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return insert(role,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public int[] insertBatch(List<Role> roles){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insertBatch(roles,conn);
	}
	
	public int[] insertBatch(List<Role> roles,Connection conn){
		return insertBatch(roles,conn,TABLE_NAME);
	}
	
	public int[] insertBatch(List<Role> roles,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return insertBatch(roles,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public int[] insertBatch(List<Role> roles,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return insertBatch(roles,conn,tableName);
	}
	
	public int[] insertBatch(List<Role> roles,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "INSERT INTO " +tableName+ " (id,cid,player_id,favor,mood,status,create_date,modified_date,unlock_gift,unlock_hobby,dress_dating,donate_dating,last_mood_update_time,work_building_id,critical_point,trigger_dating,today_city_dating_count,last_refresh_time) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		try {
			int columnSize = 18;
			int size = roles.size();
			Object[][] params = new Object[size][columnSize];
			for (int i = 0; i < size; i++) {
				params[i][0] =roles.get(i).getId();
				params[i][1] =roles.get(i).getCid();
				params[i][2] =roles.get(i).getPlayerId();
				params[i][3] =roles.get(i).getFavor();
				params[i][4] =roles.get(i).getMood();
				params[i][5] =roles.get(i).getStatus();
				params[i][6] =roles.get(i).getCreateDate();
				params[i][7] =roles.get(i).getModifiedDate();
				params[i][8] =roles.get(i).getUnlockGiftByte();
				params[i][9] =roles.get(i).getUnlockHobbyByte();
				params[i][10] =roles.get(i).getDressDatingByte();
				params[i][11] =roles.get(i).getDonateDatingByte();
				params[i][12] =roles.get(i).getLastMoodUpdateTime();
				params[i][13] =roles.get(i).getWorkBuildingId();
				params[i][14] =roles.get(i).isCriticalPoint();
				params[i][15] =roles.get(i).getTriggerDatingByte();
				params[i][16] =roles.get(i).getTodayCityDatingCount();
				params[i][17] =roles.get(i).getLastRefreshTime();
			}
			int[] is = run.batch(conn,sql,params);
			return is.length > 0 ? is : new int[]{};
		} catch (Exception e) {
			log.error(e);
			return new int[]{};
		} finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
	}
	
	public int[] insertBatch(List<Role> roles,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return insertBatch(roles,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public Role update(Role role){
		Connection conn = DataSourceManager.me().getMainConnection();
		return update(role,conn);
	}
	
	public Role update(Role role,Connection conn){
		return update(role,conn,TABLE_NAME);
	}
	
	public Role update(Role role,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return update(role,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public Role update(Role role,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return update(role,conn,tableName);
	}
	
	public Role update(Role role,Connection conn,String tableName){
		List<Role> roles = new ArrayList<Role>();
		roles.add(role);
		updateBatch(roles,conn,tableName);
		return role;
	}
	
	public Role update(Role role,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return update(role,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public int[] updateBatch(List<Role> roles){
		Connection conn = DataSourceManager.me().getMainConnection();
		return updateBatch(roles,conn);
	}
	
	public int[] updateBatch(List<Role> roles,Connection conn){
		return updateBatch(roles,conn,TABLE_NAME);
	}
	
	public int[] updateBatch(List<Role> roles,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return updateBatch(roles,conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public int[] updateBatch(List<Role> roles,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return updateBatch(roles,conn,tableName);
	}
	
	public int[] updateBatch(List<Role> roles,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "UPDATE " +tableName+ " SET id = ?,cid = ?,player_id = ?,favor = ?,mood = ?,status = ?,create_date = ?,modified_date = ?,unlock_gift = ?,unlock_hobby = ?,dress_dating = ?,donate_dating = ?,last_mood_update_time = ?,work_building_id = ?,critical_point = ?,trigger_dating = ?,today_city_dating_count = ?,last_refresh_time = ? WHERE id = ?";
		try {
			int columnSize = 18;
			int size = roles.size();
			Object[][] params = new Object[size][columnSize + 1];
			for (int i = 0; i < size; i++) {
				params[i][0] =roles.get(i).getId();
				params[i][1] =roles.get(i).getCid();
				params[i][2] =roles.get(i).getPlayerId();
				params[i][3] =roles.get(i).getFavor();
				params[i][4] =roles.get(i).getMood();
				params[i][5] =roles.get(i).getStatus();
				params[i][6] =roles.get(i).getCreateDate();
				params[i][7] =roles.get(i).getModifiedDate();
				params[i][8] =roles.get(i).getUnlockGiftByte();
				params[i][9] =roles.get(i).getUnlockHobbyByte();
				params[i][10] =roles.get(i).getDressDatingByte();
				params[i][11] =roles.get(i).getDonateDatingByte();
				params[i][12] =roles.get(i).getLastMoodUpdateTime();
				params[i][13] =roles.get(i).getWorkBuildingId();
				params[i][14] =roles.get(i).isCriticalPoint();
				params[i][15] =roles.get(i).getTriggerDatingByte();
				params[i][16] =roles.get(i).getTodayCityDatingCount();
				params[i][17] =roles.get(i).getLastRefreshTime();
				params[i][columnSize] =roles.get(i).getId();
			}
			int[] is = run.batch(conn,sql,params);
			return is.length > 0 ? is : new int[]{};
		} catch (Exception e) {
			log.error(e);
			return new int[]{};
		} finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
	}
	
	public int[] updateBatch(List<Role> roles,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return updateBatch(roles,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public boolean delete(Role role){
		Connection conn = DataSourceManager.me().getMainConnection();
		return delete(role,conn);
	}
	
	public boolean delete(Role role,Connection conn){
		return delete(role,conn,TABLE_NAME);
	}
	
	public boolean delete(Role role,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return delete(role,conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean delete(Role role,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return delete(role,conn,tableName);
	}
	
	public boolean delete(Role role,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "DELETE FROM " + tableName + " WHERE id = ?";
		try {
			int i = run.update(conn,sql, role.getId());
			return i > 0 ? true : false;
		} catch (Exception e) {
			log.error(e);
			return false;
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean delete(Role role,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return delete(role,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	
	public boolean deleteBatch(List<Role> roles){
		Connection conn = DataSourceManager.me().getMainConnection();
		return deleteBatch(roles,conn);
	}
	
	public boolean deleteBatch(List<Role> roles,Connection conn){
		return deleteBatch(roles,conn,TABLE_NAME);
	}
	
	public boolean deleteBatch(List<Role> roles,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return deleteBatch(roles,conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean deleteBatch(List<Role> roles,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return deleteBatch(roles,conn,tableName);
	}
	
	public boolean deleteBatch(List<Role> roles,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "DELETE FROM " + tableName + " WHERE id = ?";
		try {
			int size = roles.size();
			Object[][] params = new Object[size][1];
			for (int i = 0; i < size; i++) {
				params[i][0] = roles.get(i).getId();
			}
			int[] is = run.batch(conn,sql,params);
			return is.length > 0;
		} catch (Exception e) {
			log.error(e);
			return false;
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean deleteBatch(List<Role> roles,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return deleteBatch(roles,conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}

	/**
	 * 根据( id ) 查询
	 */
	public Role getById(long id){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getById(id, conn);
	}
	
	public Role getById(long id,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getById(id, conn,tableName);
	}
	public List<Role> getIn(Set<Long> ids){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getIn(ids, conn);
	}
	
	public List<Role> getIn(Set<Long> ids,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getIn(ids, conn,tableName);
	}
	/**
	 * 根据( cid  player_id ) 查询
	 */
	public Role getByCidPlayerId(int cid, int playerId){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByCidPlayerId(cid,playerId, conn);
	}
	
	public Role getByCidPlayerId(int cid, int playerId,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByCidPlayerId(cid,playerId, conn,tableName);
	}
	/**
	 * 根据( player_id ) 查询
	 */
	public List<Role> getByPlayerId(int playerId){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByPlayerId(playerId, conn);
	}
	
	public List<Role> getByPlayerId(int playerId,String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByPlayerId(playerId, conn,tableName);
	}
	
	public List<Role> getByPagePlayerId(int playerId,int page,int pageSize){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByPagePlayerId(playerId, conn,page,pageSize);
	}
	
	public List<Role> getByPagePlayerId(int playerId,String tableName,int page,int pageSize){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getByPagePlayerId(playerId, conn,tableName,page,pageSize);
	}
	
	//Connection
	/**
	 * 根据( id ) 查询
	 */
	public Role getById(long id,Connection conn){
		return getById(id,conn,TABLE_NAME);
	}
	
	public Role getById(long id,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,cid,player_id,favor,mood,status,create_date,modified_date,unlock_gift,unlock_hobby,dress_dating,donate_dating,last_mood_update_time,work_building_id,critical_point,trigger_dating,today_city_dating_count,last_refresh_time FROM " + tableName + " WHERE " + "id = ? ORDER BY id ASC LIMIT 1";
		Role role = null; 
		try {
			role = run.query(conn,sql, new RoleHandler(), id);
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return role;
	}
	public List<Role> getIn(Set<Long> ids,Connection conn){
		return getIn(ids,conn,TABLE_NAME);
	}
	
	public List<Role> getIn(Set<Long> ids,Connection conn,String tableName){
		List<Role> roles = Lists.newArrayList();
		if(ids.isEmpty()) return roles;
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,cid,player_id,favor,mood,status,create_date,modified_date,unlock_gift,unlock_hobby,dress_dating,donate_dating,last_mood_update_time,work_building_id,critical_point,trigger_dating,today_city_dating_count,last_refresh_time FROM " + tableName + " WHERE " + "id in (%s) ORDER BY id ASC";
		sql = String.format(sql, Joiner.on(",").join(ids));
		try {
			roles = run.query(conn,sql, new RoleListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return roles;
	}
	/**
	 * 根据( cid  player_id ) 查询
	 */
	public Role getByCidPlayerId(int cid, int playerId,Connection conn){
		return getByCidPlayerId(cid,playerId,conn,TABLE_NAME);
	}
	
	public Role getByCidPlayerId(int cid, int playerId,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,cid,player_id,favor,mood,status,create_date,modified_date,unlock_gift,unlock_hobby,dress_dating,donate_dating,last_mood_update_time,work_building_id,critical_point,trigger_dating,today_city_dating_count,last_refresh_time FROM " + tableName + " WHERE " + "cid = ? AND player_id = ? ORDER BY id ASC LIMIT 1";
		Role role = null; 
		try {
			role = run.query(conn,sql, new RoleHandler(), cid,playerId);
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return role;
	}
	/**
	 * 根据( player_id ) 查询
	 */
	public List<Role> getByPlayerId(int playerId,Connection conn){
		return getByPlayerId(playerId,conn,TABLE_NAME);
	}
	
	public List<Role> getByPlayerId(int playerId,Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,cid,player_id,favor,mood,status,create_date,modified_date,unlock_gift,unlock_hobby,dress_dating,donate_dating,last_mood_update_time,work_building_id,critical_point,trigger_dating,today_city_dating_count,last_refresh_time FROM " + tableName + " WHERE " + "player_id = ? ORDER BY id ASC";
		List<Role> roles = Lists.newArrayList();
		try {
			roles = run.query(conn, sql, new RoleListHandler(), playerId);
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return roles;
	}
	
	//-----------------------------------page-----------------------------------
	public List<Role> getByPagePlayerId(int playerId,Connection conn,int page,int pageSize){
		return getByPagePlayerId(playerId,conn,TABLE_NAME,page,pageSize);
	}
	
	public List<Role> getByPagePlayerId(int playerId,Connection conn,String tableName,int page,int pageSize){
		QueryRunner run = new QueryRunner();
		page = ((page-1) * pageSize);
		String sql = "SELECT id,cid,player_id,favor,mood,status,create_date,modified_date,unlock_gift,unlock_hobby,dress_dating,donate_dating,last_mood_update_time,work_building_id,critical_point,trigger_dating,today_city_dating_count,last_refresh_time FROM " + tableName + " WHERE " + "player_id = ? ORDER BY id ASC LIMIT " + page + " , " +pageSize;
		List<Role> roles = Lists.newArrayList();
		try {
			roles = run.query(conn, sql, new RoleListHandler(), playerId);
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return roles;
	}
	
	//DataSource
	/**
	 * 根据( id ) 查询
	 */
	public Role getById(long id,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getById(id, conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public Role getById(long id,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getById(id, conn, tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	public List<Role> getIn(Set<Long> ids,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getIn(ids, conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Role> getIn(Set<Long> ids,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getIn(ids, conn, tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	/**
	 * 根据( cid  player_id ) 查询
	 */
	public Role getByCidPlayerId(int cid, int playerId,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getByCidPlayerId(cid,playerId, conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public Role getByCidPlayerId(int cid, int playerId,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getByCidPlayerId(cid,playerId, conn, tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	/**
	 * 根据( player_id ) 查询
	 */
	public List<Role> getByPlayerId(int playerId,DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getByPlayerId(playerId, conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Role> getByPlayerId(int playerId,DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getByPlayerId(playerId, conn, tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	//-----------------------------------page-----------------------------------
	public List<Role> getByPagePlayerId(int playerId,DataSource ds,int page,int pageSize){
		try {
			Connection conn = ds.getConnection();
			return getByPagePlayerId(playerId, conn,page,pageSize);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Role> getByPagePlayerId(int playerId,DataSource ds,String tableName,int page,int pageSize){
		try {
			Connection conn = ds.getConnection();
			return getByPagePlayerId(playerId, conn,page,pageSize);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	
	public List<Role> getAll(){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAll(conn);
	}
	
	public List<Role> getAll(Connection conn){
		return getAll(conn,TABLE_NAME);
	}
	
	public List<Role> getAll(DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return getAll(conn);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Role> getAll(String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAll(conn,tableName);
	}
	
	public List<Role> getAll(Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "SELECT id,cid,player_id,favor,mood,status,create_date,modified_date,unlock_gift,unlock_hobby,dress_dating,donate_dating,last_mood_update_time,work_building_id,critical_point,trigger_dating,today_city_dating_count,last_refresh_time FROM " + tableName + " ORDER BY id ASC";
		List<Role> roles = Lists.newArrayList();
		try {
			roles = run.query(conn, sql, new RoleListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return roles;
	}
	
	public List<Role> getAll(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return getAll(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public List<Role> getAllPage(int page,int pageSize){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAllPage(conn,page,pageSize);
	}
	
	public List<Role> getAllPage(Connection conn,int page,int pageSize){
		return getAllPage(conn,TABLE_NAME,page,pageSize);
	}
	
	public List<Role> getAllPage(DataSource ds,int page,int pageSize){
		try {
			Connection conn = ds.getConnection();
			return getAllPage(conn,page,pageSize);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Role> getAllPage(String tableName,int page,int pageSize){
		Connection conn = DataSourceManager.me().getMainConnection();
		return getAllPage(conn,tableName,page,pageSize);
	}
	
	public List<Role> getAllPage(Connection conn,String tableName,int page,int pageSize){
		QueryRunner run = new QueryRunner();
		page = ((page-1) * pageSize);
		String sql = "SELECT id,cid,player_id,favor,mood,status,create_date,modified_date,unlock_gift,unlock_hobby,dress_dating,donate_dating,last_mood_update_time,work_building_id,critical_point,trigger_dating,today_city_dating_count,last_refresh_time FROM " + tableName + " ORDER BY id ASC LIMIT " + page + " , " +pageSize;
		List<Role> roles = Lists.newArrayList();
		try {
			roles = run.query(conn, sql, new RoleListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return roles;
	}
	
	public List<Role> getAllPage(DataSource ds,String tableName,int page,int pageSize){
		try {
			Connection conn = ds.getConnection();
			return getAllPage(conn,tableName,page,pageSize);
		} catch (Exception e) {
			log.error(e);
			return null;
		}		
	}
	
	public boolean truncate(){
		Connection conn = DataSourceManager.me().getMainConnection();
		return truncate(conn);
	}
	
	public boolean truncate(Connection conn){
		return truncate(conn,TABLE_NAME);
	}
	
	public boolean truncate(DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return truncate(conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean truncate(String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return truncate(conn,tableName);
	}
	
	public boolean truncate(Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "TRUNCATE " + tableName;
		try {
			run.update(conn, sql);
			return true;
		} catch (Exception e) {
			log.error(e);
			return false;
		} finally {
			try {
				DbUtils.close(conn);
			} catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean truncate(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return truncate(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	// 执行自定义查询sql
	public List<Map<String,Object>> executeQuerySql(String sql){
		Connection conn = DataSourceManager.me().getMainConnection();
		return executeQuerySql(conn,sql);
	}
	
	public List<Map<String,Object>> executeQuerySql(Connection conn,String sql){
		return executeQuerySql(conn,TABLE_NAME,sql);
	}
	
	public List<Map<String,Object>> executeQuerySql(DataSource ds,String sql){
		try {
			Connection conn = ds.getConnection();
			return executeQuerySql(conn,sql);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	
	public List<Map<String,Object>> executeQuerySql(String tableName,String sql){
		Connection conn = DataSourceManager.me().getMainConnection();
		return executeQuerySql(conn,tableName);
	}
	
	public List<Map<String,Object>> executeQuerySql(Connection conn,String tableName,String sql){
		QueryRunner run = new QueryRunner();
		ToolError.isAndTrue(ArtifactErrorCode.SQL_PERMISSIONS_ERROR, !StrUtil.startWithIgnoreCase(sql, "SELECT"));
		List<Map<String,Object>> list = Lists.newArrayList();
		try {
			list = run.query(conn,sql, new MapListHandler());
		} catch (Exception e) {
			log.error(e);
		}finally {
			try{
				DbUtils.close(conn);
			}catch (Exception e1) {
				log.error(e1);
				return null;
			}
		}
		return list;
	}
	/**
	public List<Map<String,Object>> executeQuerySql(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return executeQuerySql(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return null;
		}
	}
	*/
	
	//
	
	//
	
	//Drop Table
	public boolean drop(){
		Connection conn = DataSourceManager.me().getMainConnection();
		return drop(conn);
	}
	
	public boolean drop(Connection conn){
		return drop(conn,TABLE_NAME);
	}
	
	public boolean drop(DataSource ds){
		try {
			Connection conn = ds.getConnection();
			return drop(conn);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean drop(String tableName){
		Connection conn = DataSourceManager.me().getMainConnection();
		return drop(conn,tableName);
	}
	
	public boolean drop(Connection conn,String tableName){
		QueryRunner run = new QueryRunner();
		String sql = "DROP TABLE " + tableName;
		try {
			run.update(conn, sql);
			return true;
		} catch (Exception e) {
			log.error(e);
			return false;
		} finally {
			try {
				DbUtils.close(conn);
			} catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean drop(DataSource ds,String tableName){
		try {
			Connection conn = ds.getConnection();
			return drop(conn,tableName);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	
	//create
	public boolean createTable(CreateTableEnum type){
		Connection conn = DataSourceManager.me().getMainConnection();
		return createTable(conn,type);
	}
	
	public boolean createTable(Connection conn,CreateTableEnum type){
		return createTable(conn,TABLE_NAME,type);
	}
	
	public boolean createTable(DataSource ds,CreateTableEnum type){
		try {
			Connection conn = ds.getConnection();
			return createTable(conn,type);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	public boolean createTable(String tableName,CreateTableEnum type){
		Connection conn = DataSourceManager.me().getMainConnection();
		return createTable(conn,tableName,type);
	}
	
	public boolean createTable(Connection conn,String tableName,CreateTableEnum type){
		QueryRunner run = new QueryRunner();
		SK_Plus plus = SK_Plus.b("CREATE TABLE IF NOT EXISTS `", tableName,"` (");
		plus.a("  `id` BIGINT(20) NOT NULL  COMMENT '',");	
		plus.a("  `cid` INT(11)   COMMENT 'remarks=配置ID',");	
		plus.a("  `player_id` INT(11) NOT NULL  COMMENT 'remarks=玩家ID',");	
		plus.a("  `favor` INT(11)   COMMENT 'remarks=好感度经验值',");	
		plus.a("  `mood` SMALLINT(4)   COMMENT 'remarks=心情值',");	
		plus.a("  `status` SMALLINT(4)   COMMENT 'remarks=精灵状态(0：为使用 1：使用)',");	
		plus.a("  `create_date` DATETIME   COMMENT '',");
		plus.a("  `modified_date` DATETIME   COMMENT '',");
		plus.a("  `unlock_gift` BLOB(65535)   COMMENT 'remarks=解锁礼品',");	
		plus.a("  `unlock_hobby` BLOB(65535)   COMMENT 'remarks=解锁爱好',");	
		plus.a("  `dress_dating` BLOB(65535)   COMMENT 'remarks=时装约会',");	
		plus.a("  `donate_dating` BLOB(65535)   COMMENT 'remarks=赠送礼物约会',");	
		plus.a("  `last_mood_update_time` DATETIME   COMMENT 'remarks=上次心情值刷新时间',");
		plus.a("  `work_building_id` INT(11)   COMMENT 'remarks=打工建筑id，没有打工则是0',");	
		plus.a("  `critical_point` TINYINT(1)   COMMENT 'remarks=好感度临界点，true则不能继续提升好感度',");	
		plus.a("  `trigger_dating` BLOB(65535)   COMMENT 'remarks=触发约会',");	
		plus.a("  `today_city_dating_count` INT(11)   COMMENT 'remarks=当日城市约会次数',");	
		plus.a("  `last_refresh_time` DATETIME   COMMENT 'remarks=上次刷新时间',");
		plus.a("  PRIMARY KEY (`id`),");
		if (CreateTableEnum.LOGIC.equals(type) || CreateTableEnum.DESIGN.equals(type)) {
			plus.a("  UNIQUE KEY `player_id_cid_idx` (`cid`,`player_id`),");
			plus.a("  KEY `fk_spirit_player1_idx` (`player_id`),");
			
		}
		if (CreateTableEnum.DESIGN.equals(type)) {
			plus.a("  CONSTRAINT `fk_reserve_date_record_role1` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
			plus.a("  CONSTRAINT `fk_spirit_player1` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,");
		}
		String sql = plus.e();
		sql = StrUtil.subPre(sql, sql.lastIndexOf(StrUtil.C_COMMA));
		sql+=") ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT='remarks=精灵(板娘)';";
		try {
			run.update(conn, sql);
			return true;
		} catch (Exception e) {
			log.error(e);
			return false;
		} finally {
			try {
				DbUtils.close(conn);
			} catch (Exception e1) {
				log.error(e1);
				return false;
			}
		}
	}
	
	public boolean createTable(DataSource ds,String tableName,CreateTableEnum type){
		try {
			Connection conn = ds.getConnection();
			return createTable(conn,tableName,type);
		} catch (Exception e) {
			log.error(e);
			return false;
		}
	}
	
	
	public String getTableName(){
		return TABLE_NAME;
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,Object>> getColumnsInfo(){
		SK_Plus sp = SK_Plus.newSK_Plus();
		sp.a("[");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"NO\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"id\",\"NULLABLE\":0,\"REMARKS\":\"\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":1,\"DATA_TYPE\":-5,\"TYPE_NAME\":\"BIGINT\",\"COLUMN_SIZE\":20}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"cid\",\"NULLABLE\":1,\"REMARKS\":\"remarks=配置ID\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":2,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"NO\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"player_id\",\"NULLABLE\":0,\"REMARKS\":\"remarks=玩家ID\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":3,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"favor\",\"NULLABLE\":1,\"REMARKS\":\"remarks=好感度经验值\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":4,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"mood\",\"NULLABLE\":1,\"REMARKS\":\"remarks=心情值\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":5,\"DATA_TYPE\":5,\"TYPE_NAME\":\"SMALLINT\",\"COLUMN_SIZE\":4}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"status\",\"NULLABLE\":1,\"REMARKS\":\"remarks=精灵状态(0：为使用 1：使用)\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":6,\"DATA_TYPE\":5,\"TYPE_NAME\":\"SMALLINT\",\"COLUMN_SIZE\":4}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"create_date\",\"NULLABLE\":1,\"REMARKS\":\"\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":7,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"modified_date\",\"NULLABLE\":1,\"REMARKS\":\"\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":8,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"unlock_gift\",\"NULLABLE\":1,\"REMARKS\":\"remarks=解锁礼品\ntype=List\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":65535,\"ORDINAL_POSITION\":9,\"DATA_TYPE\":-4,\"TYPE_NAME\":\"BLOB\",\"COLUMN_SIZE\":65535}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"unlock_hobby\",\"NULLABLE\":1,\"REMARKS\":\"remarks=解锁爱好\ntype=List\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":65535,\"ORDINAL_POSITION\":10,\"DATA_TYPE\":-4,\"TYPE_NAME\":\"BLOB\",\"COLUMN_SIZE\":65535}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"dress_dating\",\"NULLABLE\":1,\"REMARKS\":\"remarks=时装约会\ntype=List\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":65535,\"ORDINAL_POSITION\":11,\"DATA_TYPE\":-4,\"TYPE_NAME\":\"BLOB\",\"COLUMN_SIZE\":65535}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"donate_dating\",\"NULLABLE\":1,\"REMARKS\":\"remarks=赠送礼物约会\ntype=Map\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":65535,\"ORDINAL_POSITION\":12,\"DATA_TYPE\":-4,\"TYPE_NAME\":\"BLOB\",\"COLUMN_SIZE\":65535}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"last_mood_update_time\",\"NULLABLE\":1,\"REMARKS\":\"remarks=上次心情值刷新时间\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":13,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"work_building_id\",\"NULLABLE\":1,\"REMARKS\":\"remarks=打工建筑id，没有打工则是0\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":14,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"critical_point\",\"NULLABLE\":1,\"REMARKS\":\"remarks=好感度临界点，true则不能继续提升好感度\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":15,\"DATA_TYPE\":-6,\"TYPE_NAME\":\"TINYINT\",\"COLUMN_SIZE\":1}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"trigger_dating\",\"NULLABLE\":1,\"REMARKS\":\"remarks=触发约会\ntype=List\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"CHAR_OCTET_LENGTH\":65535,\"ORDINAL_POSITION\":16,\"DATA_TYPE\":-4,\"TYPE_NAME\":\"BLOB\",\"COLUMN_SIZE\":65535}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"today_city_dating_count\",\"NULLABLE\":1,\"REMARKS\":\"remarks=当日城市约会次数\",\"DECIMAL_DIGITS\":0,\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":17,\"DATA_TYPE\":4,\"TYPE_NAME\":\"INT\",\"COLUMN_SIZE\":11}").a(",");
       	sp.a("{\"TABLE_CAT\":\"dal_game_design\",\"BUFFER_LENGTH\":65535,\"IS_NULLABLE\":\"YES\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"last_refresh_time\",\"NULLABLE\":1,\"REMARKS\":\"remarks=上次刷新时间\",\"NUM_PREC_RADIX\":10,\"SQL_DATETIME_SUB\":0,\"IS_GENERATEDCOLUMN\":\"NO\",\"IS_AUTOINCREMENT\":\"NO\",\"SQL_DATA_TYPE\":0,\"ORDINAL_POSITION\":18,\"DATA_TYPE\":93,\"TYPE_NAME\":\"DATETIME\",\"COLUMN_SIZE\":19}").a(",");
        sp.a("]");
        return JsonManager.me().getJson().parse(sp.e(), List.class);
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,Object>> getIndexsInfo(){
		SK_Plus sp = SK_Plus.newSK_Plus();
		sp.a("[");
       	sp.a("{\"NON_UNIQUE\":false,\"TABLE_CAT\":\"dal_game_design\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"id\",\"INDEX_NAME\":\"PRIMARY\",\"ASC_OR_DESC\":\"A\",\"INDEX_QUALIFIER\":\"dal_game_design\",\"ORDINAL_POSITION\":1,\"CARDINALITY\":0,\"TYPE\":3}").a(",");
       	sp.a("{\"NON_UNIQUE\":false,\"TABLE_CAT\":\"dal_game_design\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"cid\",\"INDEX_NAME\":\"player_id_cid_idx\",\"ASC_OR_DESC\":\"A\",\"INDEX_QUALIFIER\":\"dal_game_design\",\"ORDINAL_POSITION\":1,\"CARDINALITY\":0,\"TYPE\":3}").a(",");
       	sp.a("{\"NON_UNIQUE\":false,\"TABLE_CAT\":\"dal_game_design\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"player_id\",\"INDEX_NAME\":\"player_id_cid_idx\",\"ASC_OR_DESC\":\"A\",\"INDEX_QUALIFIER\":\"dal_game_design\",\"ORDINAL_POSITION\":2,\"CARDINALITY\":0,\"TYPE\":3}").a(",");
       	sp.a("{\"NON_UNIQUE\":true,\"TABLE_CAT\":\"dal_game_design\",\"TABLE_NAME\":\"role\",\"COLUMN_NAME\":\"player_id\",\"INDEX_NAME\":\"fk_spirit_player1_idx\",\"ASC_OR_DESC\":\"A\",\"INDEX_QUALIFIER\":\"dal_game_design\",\"ORDINAL_POSITION\":1,\"CARDINALITY\":0,\"TYPE\":3}").a(",");
        sp.a("]");
        return JsonManager.me().getJson().parse(sp.e(), List.class);
	}
//自定义内容起始位置
class RoleHandler implements ResultSetHandler<Role>{
	@Override
	public Role handle(ResultSet rs) throws SQLException {
		return rs.next() ? Role.builder().createForResultSet(rs).syncIndexValues() : null ;
	}
}

class RoleListHandler extends AbstractListHandler<Role>{
	@Override
	protected Role handleRow(ResultSet rs) throws SQLException {
		return Role.builder().createForResultSet(rs).syncIndexValues();
	}
}

//自定义内容结束位置
}

